package net.rock.eshop.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 *  设置虚拟路径 访问绝对路径下资源
 */
@Configuration
public class UploadConfig implements WebMvcConfigurer {
    @Value("${file.uploadPath}")
    private String uploadPath;
    @Value("${file.staticPath}")
    private String imgPath;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(imgPath).addResourceLocations("file:///" + System.getProperty("user.dir") + "/" + uploadPath);
    }
}
